package com.xintoucloud.pbs.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xintoucloud.pbs.dao.PartyPaymentDao;
import com.xintoucloud.pbs.entity.PartyPayment;
import com.xintoucloud.pbs.model.PartyMembershipDuesDto;
import com.xintoucloud.pbs.service.PartyPaymentService;
@Service
@Transactional
public class PartyPaymentServiceImpl implements PartyPaymentService{
	@Autowired
	private PartyPaymentDao partyPaymentDao;
	@Override
	public boolean savePartyPayment(PartyPayment partypayment) {
		return partyPaymentDao.save(partypayment)!=null;
	}
	@Override
	public List<PartyMembershipDuesDto> list() {
		List<PartyMembershipDuesDto> pmdds = new ArrayList<>();
		List<PartyPayment> list = partyPaymentDao.list();
		for (PartyPayment partyPayment : list) {
			PartyMembershipDuesDto pmdd = new PartyMembershipDuesDto();
			pmdd.setPartyPaymentId(partyPayment.getPartyPaymentId());
			pmdd.setPname(partyPayment.getPartyMember().getPname());
			pmdd.setAmountPayable(partyPayment.getAmountPayable());
			pmdd.setPayAmount(partyPayment.getPayAmount());
			pmdds.add(pmdd);
		}
		return pmdds;
	}
	@Override
	public void update(PartyPayment partypayment) {
		partyPaymentDao.update(partypayment);
		
	}

}
